#include <string>

#include "SymbolTable.h"



SymbolTable::SymbolTable(void) {
}

SymbolTable::~SymbolTable(void) {
}

// If string already exists in symbolTable, then return false.
// Otherwise, insert the std::pair<string, DesignEntityType> normally into the symbolTable.
/*
bool SymbolTable::insert(string symbol, DesignEntityType designentity_type) {
	// WRITE CODE HERE to
	// insert!

	return true;
}
*/
// If the string does not exist in the symbolTable, return NULL.
// Otherwise, returns the DesignEntityType of this symbol
DesignEntityType SymbolTable::getDesignEntityType(std::string symbol) {

	std::map<string, DesignEntityType>::iterator itr = mSynonymTable.find(symbol);
	if (itr == mSynonymTable.end()) {
		return INVALID_DESIGN_ENTITY;
	}
	return itr->second;
	
}

bool SymbolTable::addSynonym(DesignEntityType designEntity, string symbol) {

	
	DesignEntityType type = getDesignEntityType(symbol);
	if ( type == INVALID_DESIGN_ENTITY || type == designEntity) {
		mSynonymTable.insert(pair<string, DesignEntityType> (symbol, designEntity));
		return true;
	} else return false;
}

